//
//  CCQSearchView.swift
//  NEWweibo
//
//  Created by 神威 on 16/9/19.
//  Copyright © 2016年 ccq. All rights reserved.
//

import UIKit

class CCQSearchView: UIView {

    @IBOutlet weak var searchTextFieldRightConstrair: NSLayoutConstraint!
    @IBOutlet weak var searchButton: UIButton!
  
    @IBOutlet weak var searchTextField: UITextField!
    @IBAction func editBeginAction(_ sender: AnyObject) {
        
        searchTextFieldRightConstrair.constant = searchButton.width
        
        UIView.animate(withDuration: 0.3){
            self.layoutIfNeeded()
        }
    }
    
    @IBAction func searchButton(_ sender: AnyObject) {
        //失去第一响应者
        searchTextField.resignFirstResponder()
        searchTextFieldRightConstrair.constant = 0
    }
    //使用类方法创建xib对象
    
    class func sharedSearchView() ->CCQSearchView{
        
        return UINib(nibName: "CCQSearchView", bundle: nil).instantiate(withOwner: nil
            , options: nil).last! as!CCQSearchView
    }
    
//    override func awakeFromNib() {
//        searchTextField.layer.borderColor = UIColor.red.cgColor
//        searchTextField.layer.borderWidth = 2
//        searchTextField.layer.cornerRadius = 5
//        searchTextField.layer.masksToBounds = true
//    }
}
